//
//  AbilityChanged.h
//  This file is part of D&D Manager
//
//  Created by Matthew Hutton on 25/02/2007.
//
//
//D&D Manager, a D&D Character and battle management program.
//Copyright (C) 2007, Matthew Hutton
//
//This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License along with this program; if not, write to:
//The Free Software Foundation, Inc.,
//51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

#import <Cocoa/Cocoa.h>

/*!
* Contains character and weapon related fixed methods, not to be instansised or call things directly in the UI.
* Copyright (c)  2007 Matthew Hutton
* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
* A copy of the license is included in the section entitled "GNU Free Documentation License". 
*/
@interface AbilityChanged : NSObject {
	
}
/*!
*  Method run when a characters strength is changed, melee attack bonus and related skills also changed.
* \param obj the character in question
*/
+(void)strengthChangedForChar:(NSManagedObject *)obj;
/*!
*  Method run when a characters dexterity is changed, melee/ranged attack bonus, dex ac bonus, reflex saving throws and related skills also changed.
* \param obj the character in question
*/
+(void)dexterityChangedForChar:(NSManagedObject *)obj;
/*!
*  Method run when a characters constitution is changed, hit points, fortitude saving throws and related skills also changed.
* \param obj the character in question
*/
+(void)constitutionChangedForChar:(NSManagedObject *)obj;
/*!
*  Method run when a characters intelligence is changed, classes with intelligence as a key ability have ability related bonus spells updated and related skills also changed.
* \param obj the character in question

*/
+(void)intelligenceChangedForChar:(NSManagedObject *)obj;
/*!
*  Method run when a characters wisdom is changed, will saving throws, classes with wisdom as a key ability have ability related bonus spells updated and related skills also changed.
* \param obj the character in question
*/
+(void)wisdomChangedForChar:(NSManagedObject *)obj;
/*!
*  Method run when a characters charisma is changed, turn undead is setup, classes with charisma as a key ability have ability related bonus spells updated and related skills also changed.
* \param obj the character in question

*/
+(void)charismaChangedForChar:(NSManagedObject *)obj;
//value transformers.
/*!
*  finds the bonus value for the given score value, i.e. 8/9 goes to -1 10/11 goes to +0, 12/13 to +1 etc. etc.
* \param score the value to be turned into a bonus
* \return the bonus value found
*/
+(int)scoreToBonus:(NSNumber *)score;
/*!
*  Finds the number of bonus spells as on http://www.d20srd.org/srd/theBasics.htm#abilityScores .
* \param obj the character being processed.
* \param characterClass the character class being questioned.
* \param level the level of spell being checked.
* \return if the level is 0 or less or the appropriate ability score is less than 12 then it returns 0, otherwise it returns the appropriate value as per the table.
*/
+(int)bonusSpellsForCharacter:(NSManagedObject *)obj
	forCharacterClass:(NSManagedObject *)characterClass
			 forLevel:(int)level;
/*!
*  finds the dexterity ac bonus from the max dex bonus value chosen for the character
* \param obj the character in question
* \return the dexterity ac bonus as an integer.
*/
+(int)dexACBonus:(NSManagedObject*)obj;
/*!
* Finds the full attack bonus for the given weapon. This includes strength/dexterity bonus, weapon specific bonus, misc attack bonus, base attack bonus, and any differences caused by two-weapon fighting.
* \param weap the weapon we are finding the attack bonus for.
* \return the full attack bonus found.
*/
+(int)abilityAttackBonus:(id)weap;
/*!
*  Finds the strength bonus to damage for the given weapon, this includes the 1.5x bonus damage for melee two-handed weapon and takes into account minimum strength bonuses for ranged weapons.
* \param weap the weapon in question.
* \return the strength bonus found.
* 
*/
+(int)strengthWeaponBonus:(id)weap;
//alignment checkers.
/*!
* Finds whether or not the character is of good alignment.
* \param obj the character in question.
* \return YES if the character is good NO otherwise
*/
+(BOOL)isGood:(NSManagedObject *)obj;
/*!
* Finds whether or not the character is of evil alignment.
 * \param obj the character in question.
 * \return YES if the character is evil NO otherwise
 */
+(BOOL)isEvil:(NSManagedObject *)obj;
/*!
* Finds whether or not the character is of lawful alignment.
 * \param obj the character in question.
 * \return YES if the character is lawful NO otherwise
 */
+(BOOL)isLawful:(NSManagedObject *)obj;
/*!
* Finds whether or not the character is of chaotic alignment.
 * \param obj the character in question.
 * \return YES if the character is chaotic NO otherwise
 */
+(BOOL)isChaotic:(NSManagedObject *)obj;
//testing methods
/*!
 *  tests the skill for the given difficulty class, uses the method runTestWithBonus:forDC to do this.
 * \param skill the skill being tested
 * \param dc the difficulty class of the test
 * \returns a string containing the roll and whether or not it was successful, also says if the roll was a critical failure if a 1 is rolled.
 */
+(NSString *)runTestSkill:(NSManagedObject *)skill
			forDC:(int)dc;
/*!
 *  Rolls a d20 test with the given bonus against the given difficulty class.
 * \param bonus the bonus value for the test being carried out
 * \param dc the difficulty class of the test
 * \returns a string containing the roll and whether or not it was successful, also says if the roll was a critical failure if a 1 is rolled.
 */
+(NSString *)runTestWithBonus:(int)bonus
				forDC:(int)dc;
//gender
/*!
 * \param obj the character in question.
 * \return The nominative (he/she/it) of the gender of the character.
 */
+(NSString *)getGenderOfCharacter:(NSManagedObject *)obj;
/*!
 * \param obj the character in question.
 * \return The objective (him/her/it) of the gender of the character.
 */
+(NSString *)getTPSGenderOfCharacter:(NSManagedObject *)obj;
/*!
 * \param obj the character in question.
 * \return The possessive (his/her/their) of the gender of the character.
 */
+(NSString *)getAdjGenderOfCharacter:(NSManagedObject *)obj;
//weapons.
/*!
 * updates the default weapon text for the character, as well as removing the offWeapon relationship if the defaultWeapon is the same one, also calls ::+(void)updateShieldBonusForChar:(NSManagedObject *)obj forWeapon:(NSManagedObject *)weap in this class.
 * \param obj the character in question.
 * \return The name of the default weapon to be displayed.
 */
+(NSString *)updateDefaultWeaponForChar:(NSManagedObject *)obj;
/*!
 * Checks the weapon in question to see if it allows shield use, and updates the flat and total armour classes of the character accordingly.
 * \param obj the character in question
 * \param weap the weapon being checked
 */
+(void)updateShieldBonusForChar:(NSManagedObject *)obj
			  forWeapon:(NSManagedObject *)weap;
/*!
 * Sets the new weapon as the default weapon for the character, calls updateDefaultWeaponForChar: afterwards.
 * \param obj the character in question
 * \param newWeap the weapon being set as the default weapon
 */
+(void)setDefaultWeaponForChar:(NSManagedObject *)obj
			withWeapon:(NSManagedObject *)newWeap;
/*!
 * Checks whether the character supports an off hand weapon currently and if so then sets the new weapon as the off hand weapon for the character, calls updateDefaultWeaponForChar: afterwards.
 * \param obj the character in question
 * \param newWeap the weapon being set as the default weapon
 */
+(void)setOffHandWeaponForChar:(NSManagedObject *)obj
			withWeapon:(NSManagedObject *)newWeap;
/*!
 * Removes the current off hand weapon from the character, calls updateDefaultWeaponForChar: afterwards.
 * \param obj the character in question
 */
+(void)cancelOffHandWeaponForChar:(NSManagedObject *)obj;
//level or XP stuff.
/*!
 * Sets the level and experience up for the character and displays the xp too high or too low messages as required, sets up the cleric level for turning as well and calls setupBaseAttackEtcForCharacter:bonusLimitedToL20: and getNumberOfFeatsForTheCharacter:.
 *\param obj the character in question
 *\param characterClass the character class whose level is changing.
 *\param limited whether the file limits constitution bonus, extra attribute points base attack bonus and saving throws to level 20.
 */
+(void)setLevelOrXPForChar:(NSManagedObject *)obj
		 forCharacterClass:(NSManagedObject *)characterClass
		 bonusLimitedToL20:(BOOL)limited;
//character searching.
/*!
 * Searches through the array given to find the character with the most hit points lost.
 * \param arrayOfChars the array of characters in question.
 * \return the character in arrayOfChars which has lost the most hit points
 */
+(NSManagedObject *)findTheCharacterWithMostHPLostInTheArray:(NSArray *)arrayOfChars;
//setup base attack.
/*!
 * Checks whether auto-setup of base attack bonus etc. is enabled and if so auto-sets base attack and saving throws.
 *\param obj the character being setup.
 *\param limited whether the bonus value is limited to level 20 or not
 */
+(void)setupBaseAttackEtcForCharacter:(NSManagedObject *)obj
			bonusLimitedToL20:(BOOL)limited;
/*!
 * Finds the number of feats available for the character and sets them to the noOfBonusFeats, noOfBaseFeats and noOfTotalFeats properties for the character.
 *\param obj the current character.
 */
+(void)getNumberOfFeatsForTheCharacter:(NSManagedObject *)obj;
/*!
 *  Calculated the constitution bonus to hit points.
 * \param obj the character in question
 * \param limited whether the bonus value is limited to level 20 or not
 */
+(int)conHPBonusForCharacter:(NSManagedObject *)obj
		   bonusLimitedToL20:(BOOL)limited;
//skills
/*!
 * Sets up the ability bonus for the skill in question, gets the character from the skill.
 * \param skill the skill in question.
 */
+(void)setupSkillAbilityBonusForSkill:(NSManagedObject *)skill;
/*!
 *  sets up the global spell levels as required for the character class.
 * \param characterClass the character class in question.
 */
+(void)setupGlobalSpellLevelsForCharacterClass:(NSManagedObject *)characterClass;
/*!
 * Sets up the default values for the character class in question, if it isn't built in no values are set.
 * \param characterClass the character class in question.
 * \param globalSpellLevel the globalSpellLevel object being setup.
 */
+(void)setupStandardGlobalSpellLevelsForCharacterClass:(NSManagedObject *)characterClass
												forGSL:(NSManagedObject *)globalSpellLevel;
/*!
 * Sets up the ability bonus for the skill in question from the appropriate ability from the character.
 * \param skill the skill in question.
 * \param obj the character in question.
 */
+(void)setupSkillAbilityBonusForSkill:(NSManagedObject *)skill
				 forCharacter:(NSManagedObject *)obj;
/*!
 * Switches on/off and sets up the armour check penalty for the skill based on the value for the character.
 * \param skill the skill in question
 * \param obj the character in question
 * \param wasOn whether the armour check penalty was on
 * \param isOn whether the armour check penalty should be on.
 */
+(void)processArmourCheckPenaltyForSkill:(NSManagedObject *)skill
					forCharacter:(NSManagedObject *)obj
						   wasOn:(BOOL)wasOn
							isOn:(BOOL)isOn;
/*!
 * Creates a skill object from the superskill for the character, sets up the ability bonus and armour class penalty as required.
 * \param superskill the superskill (global skill in UI) in question
 * \param obj the character in question.
 */
+(NSManagedObject *)createAndSetupSkillFromSuperskill:(NSManagedObject *)superskill
								 forCharacter:(NSManagedObject *)obj;
//turn undead stuff
/*!
 * Turn undead properties are updated.
 * \param obj the character in question
 */
+(void)updateTurnUndeadForChar:(NSManagedObject *)obj;
/*!
 * finds out if the character in question turns or rebukes undead and if it does either.
 * \param obj the character in question
 * \return YES if the character either turns or rebukes undead, NO if the character doesn't have this ability.
 */
+(BOOL)characterTurnsOrRebukesUndead:(NSManagedObject *)obj;
/*!
 * Finds the max level of turning for the characters various character classes.
 * \param obj the character in question.
 * \return The level of turning for the character. Returns zero if the character doesn't have a level in a turning class.
 */
+(int)levelOfTurningForCharacter:(NSManagedObject *)obj;
@end
